package com.example.ch01androidspringboot.service.serviceImpl;

import com.example.ch01androidspringboot.enetity.User;
import com.example.ch01androidspringboot.mapper.UserMapper;
import com.example.ch01androidspringboot.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;

import java.util.List;

@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserMapper userMapper;
    //查询所有信息
    public List<User> selectUser() {
        Example example = new Example(User.class);
        Example.Criteria criteria = example.createCriteria();
        List<User> users = userMapper.selectAll();
        return users;

    }

    //添加用用户
    public int insertUser(String username, String password, String email) {
        int i = userMapper.insertUser(username, password, email);
        return i;
    }
}
